package com.hopu.haogoumall.db.mapper;

import com.hopu.haogoumall.db.module.HaogoumallGoodsAttribute;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface HaogoumallGoodsAttributeMapper {
    @Delete({
        "delete from haogoumall_goods_attribute",
        "where goods_attribute_id = #{goodsAttributeId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer goodsAttributeId);

    @Insert({
        "insert into haogoumall_goods_attribute (goods_attribute_id, goods_id, ",
        "`attribute`, goods_attribute_value, ",
        "goods_attribute_add_time, goods_attribute_update_time, ",
        "goods_attribute_deleted)",
        "values (#{goodsAttributeId,jdbcType=INTEGER}, #{goodsId,jdbcType=INTEGER}, ",
        "#{attribute,jdbcType=VARCHAR}, #{goodsAttributeValue,jdbcType=VARCHAR}, ",
        "#{goodsAttributeAddTime,jdbcType=TIMESTAMP}, #{goodsAttributeUpdateTime,jdbcType=TIMESTAMP}, ",
        "#{goodsAttributeDeleted,jdbcType=BIT})"
    })
    int insert(HaogoumallGoodsAttribute record);

    @InsertProvider(type=HaogoumallGoodsAttributeSqlProvider.class, method="insertSelective")
    int insertSelective(HaogoumallGoodsAttribute record);

    @Select({
        "select",
        "goods_attribute_id, goods_id, `attribute`, goods_attribute_value, goods_attribute_add_time, ",
        "goods_attribute_update_time, goods_attribute_deleted",
        "from haogoumall_goods_attribute",
        "where goods_attribute_id = #{goodsAttributeId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="goods_attribute_id", property="goodsAttributeId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="goods_id", property="goodsId", jdbcType=JdbcType.INTEGER),
        @Result(column="attribute", property="attribute", jdbcType=JdbcType.VARCHAR),
        @Result(column="goods_attribute_value", property="goodsAttributeValue", jdbcType=JdbcType.VARCHAR),
        @Result(column="goods_attribute_add_time", property="goodsAttributeAddTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="goods_attribute_update_time", property="goodsAttributeUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="goods_attribute_deleted", property="goodsAttributeDeleted", jdbcType=JdbcType.BIT)
    })
    HaogoumallGoodsAttribute selectByPrimaryKey(Integer goodsAttributeId);

    @UpdateProvider(type=HaogoumallGoodsAttributeSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(HaogoumallGoodsAttribute record);

    @Update({
        "update haogoumall_goods_attribute",
        "set goods_id = #{goodsId,jdbcType=INTEGER},",
          "`attribute` = #{attribute,jdbcType=VARCHAR},",
          "goods_attribute_value = #{goodsAttributeValue,jdbcType=VARCHAR},",
          "goods_attribute_add_time = #{goodsAttributeAddTime,jdbcType=TIMESTAMP},",
          "goods_attribute_update_time = #{goodsAttributeUpdateTime,jdbcType=TIMESTAMP},",
          "goods_attribute_deleted = #{goodsAttributeDeleted,jdbcType=BIT}",
        "where goods_attribute_id = #{goodsAttributeId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(HaogoumallGoodsAttribute record);
}